package com.snow.useviewdemo.livedata

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider

/**
 * Created by zhaoyt on 1/31/23.
 * Describe:
 */
class TestViewModelFragment : Fragment {
    constructor() : super()

    private var mViewModel: MyAndroidViewModel? = null
    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        mViewModel = ViewModelProvider(
            this,
            ViewModelProvider.AndroidViewModelFactory(requireActivity().application)
        ).get(MyAndroidViewModel::class.java)
        mViewModel?.likedNumber?.observe(viewLifecycleOwner, object : Observer<Int?> {
            override fun onChanged(t: Int?) {
            }
        })
    }
}

